<template>
  <div id="safetyManage">
    <div class="title"></div>
    <div class="content">
      <el-row :gutter="40">
        <el-col :span="12">
          <div class="video safetyItem">
            <el-row>
              <el-col :span="8">
                <img
                  class="imgItem"
                  src="../../../../../static/images/video.png"
                  @click="clearAll()"
                />
              </el-col>
              <el-col :span="16">
                <el-row class="itemTexts hoverPointer">
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showVideo('total')"
                    >总数</el-col
                  >
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showVideo('common')"
                    >正常</el-col
                  >
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showVideo('fault')"
                    >故障</el-col
                  >
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showVideo('alarm')"
                    >报警</el-col
                  >
                </el-row>
                <el-row class="itemTexts hoverPointer">
                  <el-col
                    :span="6"
                    class="itemText yh_blue"
                    @click.native="showVideo('total')"
                    >{{ videoPoints.total || "15" }}</el-col
                  >
                  <el-col
                    :span="6"
                    class="itemText yh_green"
                    @click.native="showVideo('common')"
                    >{{ videoPoints.normal || "45" }}</el-col
                  >
                  <el-col
                    :span="6"
                    class="itemText yh_orange"
                    @click.native="showVideo('fault')"
                    >{{ videoPoints.fault || "2" }}</el-col
                  >
                  <el-col
                    :span="6"
                    class="itemText yh_red"
                    @click.native="showVideo('alarm')"
                    >{{ videoPoints.alarm || "2" }}</el-col
                  >
                </el-row>
              </el-col>
            </el-row>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="safetyItem">
            <el-row>
              <el-col :span="8">
                <img
                  class="imgItem"
                  @click="clearAll"
                  src="../../../../../static/images/accessControl.png"
                />
              </el-col>
              <el-col :span="16">
                <el-row class="itemTexts hoverPointer">
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showAccess('total')"
                    >总数</el-col
                  >
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showAccess('common')"
                    >正常</el-col
                  >
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showAccess('fault')"
                    >故障</el-col
                  >
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showAccess('alarm')"
                    >报警</el-col
                  >
                </el-row>
                <el-row class="itemTexts hoverPointer">
                  <el-col
                    :span="6"
                    class="itemText yh_blue"
                    @click.native="showAccess('total')"
                    >{{ accessPoints.total || "10" }}</el-col
                  >
                  <el-col
                    :span="6"
                    class="itemText yh_green"
                    @click.native="showAccess('common')"
                    >{{ accessPoints.normal || "45" }}</el-col
                  >
                  <el-col
                    :span="6"
                    class="itemText yh_orange"
                    @click.native="showAccess('fault')"
                    >{{ accessPoints.fault || "0" }}</el-col
                  >
                  <el-col
                    :span="6"
                    class="itemText yh_red"
                    @click.native="showAccess('alarm')"
                    >{{ accessPoints.alarm || "0" }}</el-col
                  >
                </el-row>
              </el-col>
            </el-row>
          </div>
        </el-col>
      </el-row>
      <el-row :gutter="40">
        <el-col :span="12">
          <div class="safetyItem">
            <el-row>
              <el-col :span="8">
                <img
                  class="imgItem"
                  @click="clearAll()"
                  src="../../../../../static/images/Invade.png"
                />
              </el-col>
              <el-col :span="16">
                <el-row class="itemTexts hoverPointer">
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showInvade('total')"
                    >总数</el-col
                  >
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showInvade('common')"
                    >正常</el-col
                  >
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showInvade('fault')"
                    >故障</el-col
                  >
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showInvade('alarm')"
                    >报警</el-col
                  >
                </el-row>
                <el-row class="itemTexts hoverPointer">
                  <el-col
                    :span="6"
                    class="itemText yh_blue"
                    @click.native="showInvade('total')"
                    >{{ invadePoints.total || "45" }}</el-col
                  >
                  <el-col
                    :span="6"
                    class="itemText yh_green"
                    @click.native="showInvade('common')"
                    >{{ invadePoints.normal || "5" }}</el-col
                  >
                  <el-col
                    :span="6"
                    class="itemText yh_orange"
                    @click.native="showInvade('fault')"
                    >{{ invadePoints.fault || "1" }}</el-col
                  >
                  <el-col
                    :span="6"
                    class="itemText yh_red"
                    @click.native="showInvade('alarm')"
                    >{{ invadePoints.alarm || "0" }}</el-col
                  >
                </el-row>
              </el-col>
            </el-row>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="safetyItem">
            <el-row>
              <el-col :span="8">
                <img
                  @click="clearAll()"
                  class="imgItem"
                  src="../../../../../static/images/fireFighting.png"
                />
              </el-col>
              <el-col :span="16">
                <el-row class="itemTexts hoverPointer">
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showFire('total')"
                    >总数</el-col
                  >
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showFire('common')"
                    >正常</el-col
                  >
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showFire('fault')"
                    >故障</el-col
                  >
                  <el-col
                    :span="6"
                    class="text"
                    @click.native="showFire('alarm')"
                    >报警</el-col
                  >
                </el-row>
                <el-row class="itemTexts hoverPointer">
                  <el-col
                    :span="6"
                    class="itemText yh_blue"
                    @click.native="showFire('total')"
                    >{{ firePoints.total || "45" }}</el-col
                  >
                  <el-col
                    :span="6"
                    class="itemText yh_green"
                    @click.native="showFire('common')"
                    >{{ firePoints.normal || "5" }}</el-col
                  >
                  <el-col
                    :span="6"
                    class="itemText yh_orange"
                    @click.native="showFire('fault')"
                    >{{ firePoints.fault || "2" }}</el-col
                  >
                  <el-col
                    :span="6"
                    class="itemText yh_red"
                    @click.native="showFire('alarm')"
                    >{{ firePoints.alarm || "1" }}</el-col
                  >
                </el-row>
              </el-col>
            </el-row>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script>
import axios from "axios";
import { TUVector2 } from "tumap/dist/tumap.v1.8.js";
export default {
  name: "safety",
  data() {
    return {
      // 存储所有的项
      allDataItems: [],

      // 后台传来的数据
      videoPoints: [],
      invadePoints: [],
      accessPoints: [],
      firePoints: [],
      allUe: [],
      count: 0,
    };
  },
  mounted() {
    this.parseTree();
    window.getTree = this.parseTree;
    axios.get('./static/json/allUEEquipment.json').then((res)=>{
      this.allUe = res.data
    })
  },

  methods: {
    parseTree() {
      var tem = JSON.parse(window.sessionStorage.getItem("treeData"));
      tem&&this.treeForeach(tem, (node) => {
        node.code && this.allDataItems.push(JSON.parse(JSON.stringify(node)));
      });
    },
    // 清除所有的poi点图标
    clearAll() {
      window.Sgworld.clearAllCovering();
      var timetype = window.sessionStorage.getItem('timeType');
      var weathertype = window.sessionStorage.getItem('weatherType');
      window.Sgworld.execute("grapi", "settime", { type: timetype }, null);
      window.Sgworld.execute("grapi", "setweather", { type: weathertype }, null);
    },

    // 视频撒点
    showVideo(type) {
      try {
        // 初始化视角
        window.viewInit();
        // 清除所有的撒点
        this.clearAll();
      } catch (error) {
        console.log(error);
      }
      // 获取所有的数据项
      var temArr = JSON.parse(JSON.stringify(this.allDataItems));
      // 保存正常的，故障的，报警的数据信息
      var Common = [],
        Fault = [],
        Alarm = [];
      if (this.videoPoints.data) {
        Common = this.videoPoints.data.filter((item) => {
          return item.state == "0";
        });
        Fault = this.videoPoints.data.filter((item) => {
          return item.state == "1" || item.state == "2";
        });
        Alarm = this.videoPoints.data.filter((item) => {
          return item.state == "3";
        });
      }
      if (Common.length == 0 && Fault.length == 0 && Alarm.length == 0) {
        this.$message("暂无数据！");
        return;
      }
      if (type == "total") {
        for (var i = 0; i < temArr.length; i++) {
          temArr[i].name =
            "视频-" +
            temArr[i].floorId +
            "_" +
            temArr[i].id +
            "-" +
            temArr[i].label;
          temArr[i].id = temArr[i].floorId + "_" + temArr[i].id;
          temArr[i].x = temArr[i].position.x;
          temArr[i].y = temArr[i].position.y;
          temArr[i].z = temArr[i].position.z;
          temArr[i].scale = 0.3;
          temArr[i].image = "";
          if (Common.length > 0) {
            for (var j = 0; j < Common.length; j++) {
              if (temArr[i].code == Common[j].code) {
                temArr[i].image =
                  window.ipUrl + "qy/static/images/popups/videoCommon.png";
                window.Sgworld.createBillboard(temArr[i]);
                break;
              }
            }
          }
          if (Fault.length > 0) {
            for (var j = 0; j < Fault.length; j++) {
              if (temArr[i].code == Fault[j].code) {
                temArr[i].image =
                  window.ipUrl + "qy/static/images/popups/videoWarning.png";
                window.Sgworld.createBillboard(temArr[i]);
                break;
              }
            }
          }
          if (Alarm.length > 0) {
            for (var j = 0; j < Alarm.length; j++) {
              if (temArr[i].code == Alarm[j].code) {
                temArr[i].image =
                  window.ipUrl + "qy/static/images/popups/videoFault.png";
                window.Sgworld.createBillboard(temArr[i]);
                break;
              }
            }
          }
        }
      } else if (type == "common") {
        for (var i = 0; i < temArr.length; i++) {
          temArr[i].name =
            "视频-" +
            temArr[i].floorId +
            "_" +
            temArr[i].id +
            "-" +
            temArr[i].label;
          temArr[i].id = temArr[i].floorId + "_" + temArr[i].id;
          temArr[i].x = temArr[i].position.x;
          temArr[i].y = temArr[i].position.y;
          temArr[i].z = temArr[i].position.z;
          temArr[i].scale = 0.3;
          temArr[i].image = "";
          if (Common.length > 0) {
            for (var j = 0; j < Common.length; j++) {
              if (temArr[i].code == Common[j].code) {
                temArr[i].image =
                  window.ipUrl + "qy/static/images/popups/videoCommon.png";
                window.Sgworld.createBillboard(temArr[i]);
                break;
              }
            }
          }
        }
      } else if (type == "fault") {
        for (var i = 0; i < temArr.length; i++) {
          temArr[i].name =
            "视频-" +
            temArr[i].floorId +
            "_" +
            temArr[i].id +
            "-" +
            temArr[i].label;
          temArr[i].id = temArr[i].floorId + "_" + temArr[i].id;
          temArr[i].x = temArr[i].position.x;
          temArr[i].y = temArr[i].position.y;
          temArr[i].z = temArr[i].position.z;
          temArr[i].scale = 0.3;
          temArr[i].image = "";
          if (Fault.length > 0) {
            for (var j = 0; j < Fault.length; j++) {
              if (temArr[i].code == Fault[j].code) {
                temArr[i].image =
                  window.ipUrl + "qy/static/images/popups/videoWarning.png";
                  try {
                    window.Sgworld.createBillboard(temArr[i]);
                  } catch (error) {
                    console.log(error)
                  }
                break;
              }
            }
          }
        }
      } else {
        for (var i = 0; i < temArr.length; i++) {
          temArr[i].name =
            "视频-" +
            temArr[i].floorId +
            "_" +
            temArr[i].id +
            "-" +
            temArr[i].label;
          temArr[i].id = temArr[i].floorId + "_" + temArr[i].id;
          temArr[i].x = temArr[i].position.x;
          temArr[i].y = temArr[i].position.y;
          temArr[i].z = temArr[i].position.z;
          temArr[i].scale = 0.3;
          temArr[i].image = "";
          if (Alarm.length > 0) {
            for (var j = 0; j < Alarm.length; j++) {
              if (temArr[i].code == Alarm[j].code) {
                temArr[i].image = window.ipUrl + "qy/static/images/popups/videoFault.png";
                try {
                  window.Sgworld.createBillboard(temArr[i]);
                } catch (error) {
                  console.log(error);
                }
                break;
              }
            }
          }
        }
      }
    },

    // 门禁撒点
    showAccess(type) {
      try {
        // 初始化视角
        window.viewInit();
        // 清除所有的撒点
        this.clearAll();
      } catch (error) {
        console.log(error);
      }
      // 获取所有的数据项
      var temArr = JSON.parse(JSON.stringify(this.allDataItems));
      // 保存正常的，故障的，报警的数据信息
      var Common = [],
        Fault = [],
        Alarm = [];
      if (this.accessPoints.data) {
        Common = this.accessPoints.data.filter((item) => {
          return item.state == "0";
        });
        Fault = this.accessPoints.data.filter((item) => {
          return item.state == "1" || item.state == "2";
        });
        Alarm = this.accessPoints.data.filter((item) => {
          return item.state == "3";
        });
      }
      if (Common.length == 0 && Fault.length == 0 && Alarm.length == 0) {
        this.$message("暂无数据！");
        return;
      }
      if (type == "total") {
        for (var i = 0; i < temArr.length; i++) {
          if (Common.length > 0) {
            for (var j = 0; j < Common.length; j++) {
              if (temArr[i].code == Common[j].code) {
                var temObj = {};
                temObj.name = "门禁管理-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image = window.ipUrl + "qy/static/images/popups/accessCommon.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
          if (Fault.length > 0) {
            for (var j = 0; j < Fault.length; j++) {
              if (temArr[i].code == Fault[j].code) {
                var temObj = {};
                temObj.name = "门禁管理-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image = window.ipUrl + "qy/static/images/popups/accessWarning.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
          if (Alarm.length > 0) {
            for (var j = 0; j < Alarm.length; j++) {
              if (temArr[i].code == Alarm[j].code) {
                var temObj = {};
                temObj.name = "门禁管理-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/accessFault.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
        }
      } else if (type == "common") {
        for (var i = 0; i < temArr.length; i++) {
          if (Common.length > 0) {
            for (var j = 0; j < Common.length; j++) {
              if (temArr[i].code == Common[j].code) {
                var temObj = {};
                temObj.name = "门禁管理-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/accessCommon.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
        }
      } else if (type == "fault") {
        for (var i = 0; i < temArr.length; i++) {
          if (Fault.length > 0) {
            for (var j = 0; j < Fault.length; j++) {
              if (temArr[i].code == Fault[j].code) {
                var temObj = {};
                temObj.name = "门禁管理-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/accessWarning.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
        }
      } else {
        for (var i = 0; i < temArr.length; i++) {
          if (Alarm.length > 0) {
            for (var j = 0; j < Alarm.length; j++) {
              if (temArr[i].code == Alarm[j].code) {
                var temObj = {};
                temObj.name = "门禁管理-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/accessFault.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
        }
      }
    },

    // 入侵撒点
    showInvade(type) {
      
      // 初始化视角
      window.viewInit();
      // 清除所有的撒点
      this.clearAll();
      // 获取所有的数据项
      var temArr = JSON.parse(JSON.stringify(this.allDataItems));
      var temArrUe = JSON.parse(JSON.stringify(this.allUe));
      // 保存正常的，故障的，报警的数据信息
      var Common = [],
        Fault = [],
        Alarm = [];
      if (this.invadePoints.data) {
        Common = this.invadePoints.data.filter((item) => {
          return item.state == "0";
        });
        Fault = this.invadePoints.data.filter((item) => {
          return item.state == "1" || item.state == "2";
        });
        Alarm = this.invadePoints.data.filter((item) => {
          return item.state == "3";
        });
      }
      if (Common.length == 0 && Fault.length == 0 && Alarm.length == 0) {
        this.$message("暂无数据！");
        return;
      }
      if (type == "total") {
        for (var i = 0; i < temArr.length; i++) {
          if (Common.length > 0) {
            for (var j = 0; j < Common.length; j++) {
              if (temArr[i].code == Common[j].code) {
                var temObj = {};
                temObj.name = "入侵管理-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/invadeCommon.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
          if (Fault.length > 0) {
            for (var j = 0; j < Fault.length; j++) {
              if (temArr[i].code == Fault[j].code) {
                var temObj = {};
                temObj.name = "入侵管理-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/invadeWarning.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
          if (Alarm.length > 0) {
            for (var j = 0; j < Alarm.length; j++) {
              if (temArr[i].code == Alarm[j].code) {
                var temObj = {};
                temObj.name = "入侵管理-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/invadeFault.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
        }
      } else if (type == "common") {
        for (var i = 0; i < temArr.length; i++) {
          if (Common.length > 0) {
            for (var j = 0; j < Common.length; j++) {
              if (temArr[i].code == Common[j].code) {
                var temObj = {};
                temObj.name = "入侵管理-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/invadeCommon.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
        }
      } else if (type == "fault") {
        for (var i = 0; i < temArr.length; i++) {
          if (Fault.length > 0) {
            for (var j = 0; j < Fault.length; j++) {
              if (temArr[i].code == Fault[j].code) {
                var temObj = {};
                temObj.name = "入侵管理-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/invadeWarning.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
        }
      } else {
        for (var i = 0; i < temArr.length; i++) {
          if (Alarm.length > 0) {
            for (var j = 0; j < Alarm.length; j++) {
              if (temArr[i].code == Alarm[j].code) {
                var temObj = {};
                temObj.name = "入侵管理-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/invadeFault.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
        }
      }
    },

    // 消防撒点
    showFire(type) {
      try {
        // 初始化视角
        window.viewInit();
        // 清除所有的撒点
        this.clearAll();
      } catch (error) {
        console.log(error);
      }
      // 获取所有的数据项
      var temArr = JSON.parse(JSON.stringify(this.allDataItems));
      // 保存正常的，故障的，报警的数据信息
      var Common = [],
        Fault = [],
        Alarm = [];
      if (this.firePoints.data) {
        Common = this.firePoints.data.filter((item) => {
          return item.state == "0";
        });
        Fault = this.firePoints.data.filter((item) => {
          return item.state == "1" || item.state == "2";
        });
        Alarm = this.firePoints.data.filter((item) => {
          return item.state == "3";
        });
      }
      if (Common.length == 0 && Fault.length == 0 && Alarm.length == 0) {
        this.$message("暂无数据！");
        return;
      }
      if (type == "total") {
        for (var i = 0; i < temArr.length; i++) {
          if (Common.length > 0) {
            for (var j = 0; j < Common.length; j++) {
              if (temArr[i].code == Common[j].code) {
                var temObj = {};
                temObj.name = "消防系统-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image = window.ipUrl + "qy/static/images/popups/fireCommon.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
          if (Fault.length > 0) {
            for (var j = 0; j < Fault.length; j++) {
              if (temArr[i].code == Fault[j].code) {
                var temObj = {};
                temObj.name = "消防系统-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image = 'http://192.168.1.8:83/qy/static/images/popups/fireCommon.png'
                  // window.ipUrl + "qy/static/images/popups/fireWarning.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
          if (Alarm.length > 0) {
            for (var j = 0; j < Alarm.length; j++) {
              if (temArr[i].code == Alarm[j].code) {
                var temObj = {};
                temObj.name = "消防系统-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/fireFault.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
        }
      } else if (type == "common") {
        for (var i = 0; i < temArr.length; i++) {
          if (Common.length > 0) {
            for (var j = 0; j < Common.length; j++) {
              if (temArr[i].code == Common[j].code) {
                var temObj = {};
                temObj.name = "消防系统-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/fireCommon.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
        }
      } else if (type == "fault") {
        for (var i = 0; i < temArr.length; i++) {
          if (Fault.length > 0) {
            for (var j = 0; j < Fault.length; j++) {
              if (temArr[i].code == Fault[j].code) {
                var temObj = {};
                temObj.name = "消防系统-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/fireWarning.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
        }
      } else {
        for (var i = 0; i < temArr.length; i++) {
          if (Alarm.length > 0) {
            for (var j = 0; j < Alarm.length; j++) {
              if (temArr[i].code == Alarm[j].code) {
                var temObj = {};
                temObj.name = "消防系统-" + temArr[i].floorId +"-" +temArr[i].code;
                temObj.id = temArr[i].floorId + "_" + temArr[i].id;
                temObj.x = temArr[i].position.x;
                temObj.y = temArr[i].position.y;
                temObj.z = temArr[i].position.z;
                temObj.scale = 0.3;
                temObj.image =
                  window.ipUrl + "qy/static/images/popups/fireFault.png";
                window.Sgworld.createBillboard(temObj);
                break;
              }
            }
          }
        }
      }
    },

    // 树的广度遍历
    treeForeach(tree, func) {
      let node,
        list = [...tree];
      while ((node = list.shift())) {
        func(node);
        node.children && list.push(...node.children);
      }
    },
  },

  sockets: {
    sendVideosStatus(data) {
      //设置视频数据
      this.videoPoints = data?JSON.parse(data):[];
    },
    sendAccessControlStatus(data) {
      //设置门禁数据
      this.accessPoints = data?JSON.parse(data):[];
    },
    sendSyInvadeStatus(data) {
      //设置入侵数据
      this.invadePoints = data?JSON.parse(data):[];
    },
    sendSyFireControlStatus(data) {
      //设置消防数据
      this.firePoints = data?JSON.parse(data):[];
    },
  },
};
</script>
<style scoped>
#safetyManage {
  padding: 5px 68px;
  box-sizing: border-box;
}
.title {
  width: 645px;
  height: 112px;
  background: url("../../../../../static/images/safe.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  margin-bottom: 10px;
  margin-left: -30px;
}
.safetyItem {
  box-sizing: border-box;
  width: 365px;
  height: 157px;
  line-height: 157px;
  background: url("../../../../../static/images/safeItem.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  cursor: pointer;
}

.imgItem {
  margin-left: 15px;
  margin-top: 30px;
}
.itemTexts {
  height: 30px;
  line-height: 30px;
  font-size: 26px;
  margin: 30px 0;
}
.itemText + .itemText {
  text-align: center;
  border-left: 1px solid white;
}
.text {
  color: #cde6f0;
  font-size: 26px;
}
</style>
